
cd

use "Main.dta", clear

** TABLE 4

** column 1

gen ratio33 = Retail1933/Retail1929

gen shock_num32 = num_susp/ntl_n29
gen shock_val32 = val_susp/ntl_d29

gen i_num32_ne20 = shock_num32*ne20
gen i_val32_ne20 = shock_val32*ne20

label variable ne20 "NE20"
label variable shock_num32 "SuspNum32"
label variable i_num32_ne20 "SuspNum32 x NE20"
label variable shock_val32 "SuspVal32"
label variable i_val32_ne20 "SuspVal32 x NE20"

xi: reg ratio33 ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 log_area log_pop urban nwnp age1844 school1620 mfgest_pc mfgwork log_mfgva farms_pc acres log_avgcrop log_avgvalue homeownclr i.district city, vce(bootstrap, reps(2500) strata(district))
outreg2 using Table4.tex, replace ctitle(Baseline) nocons keep(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20) sortvar(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20) addtext(District FE, YES, Census Controls, YES) tex(frag) dec(3) adjr2 nonote label

** column 2

gen i_num32_hhi=shock_num32*hhi
gen i_val32_hhi=shock_val32*hhi

label variable hhi "HHI"
label variable i_num32_hhi "SuspNum32 x HHI"
label variable i_val32_hhi "SuspVal32 x HHI"

xi: reg ratio33 ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi log_area log_pop urban nwnp age1844 school1620 mfgest_pc mfgwork log_mfgva farms_pc acres log_avgcrop log_avgvalue homeownclr i.district city, vce(bootstrap, reps(2500) strata(district))
outreg2 using Table4.tex, append ctitle(Control HHI) nocons keep(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi) sortvar(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi) addtext(District FE, YES, Census Controls, YES) tex(frag) dec(3) adjr2 nonote label

** column 3

rename ne20 ne20x
rename ne20d ne20

drop i_num32_ne20 i_val32_ne20
gen i_num32_ne20 = shock_num32*ne20
gen i_val32_ne20 = shock_val32*ne20
label variable i_num32_ne20 "SuspNum32 x NE20"
label variable i_val32_ne20 "SuspVal32 x NE20"

xi: reg ratio33 ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi log_area log_pop urban nwnp age1844 school1620 mfgest_pc mfgwork log_mfgva farms_pc acres log_avgcrop log_avgvalue homeownclr i.district city, vce(bootstrap, reps(2500) strata(district))
outreg2 using Table4.tex, append ctitle(Alt. NE20) nocons keep(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi) sortvar(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi) addtext(District FE, YES, Census Controls, YES) tex(frag) dec(3) adjr2 nonote label

** column 4

rename ne20 ne20d
rename ne20x ne20

drop shock_num32 shock_val32 i_num32_ne20 i_val32_ne20 i_num32_hhi i_val32_hhi

gen shock_num32 = num_fail/ntl_n29
replace shock_num32=0 if shock_num32==.

gen shock_val32 = (val_fail/1000)/ntl_d29
replace shock_val32=0 if shock_val32==.

gen i_num32_ne20 = shock_num32*ne20
gen i_val32_ne20 = shock_val32*ne20

gen i_num32_hhi=shock_num32*hhi
gen i_val32_hhi=shock_val32*hhi

label variable shock_num32 "SuspNum32"
label variable i_num32_ne20 "SuspNum32 x NE20"
label variable shock_val32 "SuspVal32"
label variable i_val32_ne20 "SuspVal32 x NE20"
label variable i_num32_hhi "SuspNum32 x HHI"
label variable i_val32_hhi "SuspVal32 x HHI"

xi: reg ratio33 ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi log_area log_pop urban nwnp age1844 school1620 mfgest_pc mfgwork log_mfgva farms_pc acres log_avgcrop log_avgvalue homeownclr i.district city, vce(bootstrap, reps(2500) strata(district))
outreg2 using Table4.tex, append ctitle(Using Failures) nocons keep(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi) sortvar(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi) addtext(District FE, YES, Census Controls, YES) tex(frag) dec(3) adjr2 nonote label

** column 5

drop shock_num32 shock_val32 i_num32_ne20 i_val32_ne20 i_num32_hhi i_val32_hhi

gen shock_num32 = num_consol/ntl_n29
replace shock_num32=0 if shock_num32==.

gen shock_val32 = (val_consol/1000)/ntl_d29
replace shock_val32=0 if shock_val32==.

gen i_num32_ne20 = shock_num32*ne20
gen i_val32_ne20 = shock_val32*ne20

gen i_num32_hhi=shock_num32*hhi
gen i_val32_hhi=shock_val32*hhi

label variable shock_num32 "SuspNum32"
label variable i_num32_ne20 "SuspNum32 x NE20"
label variable shock_val32 "SuspVal32"
label variable i_val32_ne20 "SuspVal32 x NE20"
label variable i_num32_hhi "SuspNum32 x HHI"
label variable i_val32_hhi "SuspVal32 x HHI"

xi: reg ratio33 ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi log_area log_pop urban nwnp age1844 school1620 mfgest_pc mfgwork log_mfgva farms_pc acres log_avgcrop log_avgvalue homeownclr i.district city, vce(bootstrap, reps(2500) strata(district))
outreg2 using Table4.tex, append ctitle(Using Mergers) nocons keep(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi) sortvar(ne20 shock_num32 i_num32_ne20 shock_val32 i_val32_ne20 hhi i_num32_hhi i_val32_hhi) addtext(District FE, YES, Census Controls, YES) tex(frag) dec(3) adjr2 nonote label

erase Table4.txt
